﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CoreUtils.Common
{
    /// <summary>
    /// Common function that return or solve a string
    /// </summary>
    /// <remarks>xula@vnext.vn</remarks>
    public class Strings
    {
        /// <summary>
        /// Get datetime at this moment
        /// </summary>
        /// <returns>string</returns>
        /// <remarks>xula@vnext.vn</remarks>
        public static string dateTimeStr()
        {
            return DateTime.Now.ToString("yyyyMMdd_HHmmss_f");
        }

        /// <summary>
        /// Return an unique string from datetime string
        /// </summary>
        /// <returns>string</returns>
        /// <remarks>xula@vnext.vn</remarks>
        public static string uniqueStr()
        {
            return DateTime.Now.ToString("yyyyMMdd_HHmmss_f") +
                "_" + DateTime.Now.Ticks.ToString();
        }

        public static string uniqueStr(string surfix)
        {
            return uniqueStr() + surfix;
        }

        public static string uniqueStr(string prefix, string surfix)
        {
            return prefix + uniqueStr() + surfix;
        }

        /// <summary>
        /// Check if a string is null or empty
        /// </summary>
        /// <param name="str">string checked</param>
        /// <returns>true if string is null or empty, else false</returns>
        /// <remarks>xula@vnext.vn</remarks>
        public static bool isNullEmpty(string str)
        {
            if (string.IsNullOrEmpty(str))
                return true;
            else
                return false;
        }
    }
}
